import QtQuick 2.8
import QtQuick.Controls 2.0
import QtGraphicalEffects 1.0
import QtWeChat 1.0

ApplicationWindow {
    id: root
    visible: true
    width: 280
    height: 400
    flags: Qt.FramelessWindowHint
    title: qsTr("微信")
    color: "transparent"

    background: Rectangle {
        anchors.fill: parent
        radius: 2
        color: "#F5F5F5"
        border.color: "#E7E7E7"
    }

    WeChatClient {
        id: client
        onInitialized: {
            stackView.push("qrc:/LoginPage.qml", {"login": client.login});
//            stackView.push("qrc:/MainPage.qml", {"login": client.login});
        }
        onLogined: {
            stackView.push("qrc:/MainPage.qml", {"login": client.login});
        }
    }

    StackView {
        id: stackView
        anchors.fill: parent
        initialItem: "qrc:/SplashPage.qml"
        pushEnter: Transition {
            PropertyAnimation {
                property: "opacity"
                from: 0
                to:1
                duration: 500
            }
        }
        pushExit: Transition {
            PropertyAnimation {
                property: "opacity"
                from: 1
                to:0
                duration: 200
            }
        }
    }

    Component.onCompleted: {
        client.init();
    }
}
